package com.ruoyi.web.controller.common;


import com.ruoyi.web.entity.dao.WechatLoginRequest;
import com.ruoyi.web.service.IWechatService;
import com.ruoyi.web.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/wechat")
@Api(tags = {"微信小程序"}, value = "/wechat")
@Slf4j
public class LoginController {
    @Resource
    private IWechatService wechatService;

    @ApiOperation(value = "微信登录获取openID，sesionKey", httpMethod = "POST")
    @GetMapping("/authorization")
    public ResponseResult authorization(@Validated @RequestBody WechatLoginRequest loginRequest) {
        return wechatService.getUserInfoMap(loginRequest);
    }

}
